<%-- 
    Document   : home
    Created on : 2-sep-2011, 11:18:54
    Author     : fgo
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="includes/header.jsp" %>

<script type="text/javascript">                                         

    function updateBought(id){
        $.post("<%= request.getContextPath()%>/mvc/shoppingList/${shoppingList.id}/" + id + "/toggle");
    }
   
</script>

${shoppingList.name} &nbsp;
<a href="${shoppingList.id}/addItem"><img src="<%= request.getContextPath()%>/style/new.png" alt="new" width="16px"/></a>
&nbsp;
<a target="_new" href="<%= request.getContextPath()%>/mvc/pdf/shoppingList/${shoppingList.id}">pdf</a>

<table style="margin-left: 25px;margin-top: 15px;">
    <c:forEach items="${shoppingList.shopItems}" var="item">
        <tr>
            <td>
                <a href="${shoppingList.id}/deleteItem/${item.id}">
                    <img src="<%= request.getContextPath()%>/style/delete.png" alt="delete" width="16px" />
                </a>
            </td>
            <td>
                <INPUT TYPE=CHECKBOX NAME="bought" <c:if test="${item.bought}">CHECKED</c:if> onchange="updateBought(${item.id});" />
            </td>
            <td>
                ${item.item.name}
            </td>
            <td style="text-align: right">
                ${item.amount}x
            </td>            
        </tr>
    </c:forEach>
</table>


<%@include file="includes/footer.jsp" %>
